<template>
  <div>
    <!-- table -->
    <!-- 在库车质量信息维护 - 处理检测结果 - 编辑 -->
    <BreakSpace label="基本信息" :containerStyle="{ marginBottom: '10px' }"/>
    <FormPanel ref="formPanel1" :list="formList" :cols="3" :formType="'add'" labelWidth="100" :isSubmitBtn="false"
               @formChange="formChangeHandle"/>
    <div style="margin-bottom: 1rem;"></div>
    <BreakSpace label="处理历史" :containerStyle="{ marginBottom: '10px' }"/>
    <FilterTable
      ref="table"
      :columns="columns"
      :params="fetchParams"
      :dataSource="dataList"
      :datakey="'items'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      selectionType="single"
    ></FilterTable>
    <div style="margin-bottom: 1rem;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button type="primary" :click="saveDialog.bind()">保存</multiuse-button>
      <multiuse-button type="primary" @click="">处理</multiuse-button>
      <multiuse-button type="primary" @click="closeDialog">关 闭</multiuse-button>
    </div>
  </div>
</template>
<script>
// import res from '@/mock/tableData';

export default {
  // mixins: [dictionary],
  components: {
  },
  data() {
    return {
      dataList: [],
      collapse: false,
      infoId: null,
      columns: this.creatHeader(),
      // topFilterInit: this.topFilterInitFun(),
      // fetchApi: getUser,
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      formList: this.createFormList(),
      saveData: null
    };
  },
  created() {
    // this.dataList = [...res.data.items];
    console.log(this.dataList);
  },
  methods: {
    //基本信息
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'techNo',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '入库时间',
          fieldName: 'techStatus',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '最新检测时间',
          fieldName: 'ifFirst',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '电池状态',
          fieldName: 'dealerCode',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '使用状态',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'SELECT',
          label: '使用状态',
          fieldName: 'wmStatus',
          itemList: [{text: '热点', value: '1'}, {text: '资讯', value: '2'}],
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '处理描述',
          rules: [{required: true, message: '请输入处理描述', trigger: 'change'}],
          fieldName: 'dcPerson',
          selfCols: 3,// 元素占据几行
          rows: 1
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'dcTel',
          selfCols: 3,// 元素占据几行
          rows: 1
        }
      ];
    },
    //故障信息
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '检测时间', dataIndex: 'date', sorter: true },
        { title: '电池状态', dataIndex: 'date', sorter: true },
        { title: '使用状态', dataIndex: 'date', sorter: true },
        { title: '处理状态', dataIndex: 'date', sorter: true },
        { title: '处理描述', dataIndex: 'date', sorter: true },
        { title: '维护人', dataIndex: 'date', sorter: true },
        { title: '维护时间', dataIndex: 'date', sorter: true },
        { title: '备注', dataIndex: 'date', sorter: true },

      ];
    },

    formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$refs.formPanel1.SUBMIT_FORM();
      if (this.saveData) {
        this.$emit('save', this.selectedRows);
      }
    },
    //取消操作
    closeDialog() {
      this.$emit('close', {visible: false, data: this.selectedRows, type: 'close'});
    }
  }
};
</script>

<style lang="less" scoped></style>
